/*
 * RemoteTableServer.java
 * 
 * Written by Joseph Bowbeer and released to the public domain,
 * as explained at http://creativecommons.org/licenses/publicdomain
 */

package jozart.remotetabledemo;

import java.rmi.Naming;
import java.rmi.RMISecurityManager;

import javax.swing.table.TableModel;

import jozart.remotetable.RemoteTableModelAdapter;

/**
 * Server for demo remote table model. 
 *
 * @author  Joseph Bowbeer
 * @version 1.0
 */
public class RemoteTableServer {

    /** Do not instantiate. */
    private RemoteTableServer() { }

    /**
     * Creates demo server model and binds it in the registry.
     * 
     * @param args ignored
     */
    public static void main(String[] args) {

        /* Create and install a security manager. */
        if (System.getSecurityManager() == null) {
            System.setSecurityManager(new RMISecurityManager());
        }

        try {
            //Registry reg = LocateRegistry.createRegistry(Registry.REGISTRY_PORT);
            TableModel model = DemoTableModel.createServerModel();
            RemoteTableModelAdapter adapter = new RemoteTableModelAdapter(model);
            Naming.rebind("/RemoteTableServer", adapter);
            System.out.println("RemoteTableServer bound in registry. Ready.");
        } catch (Exception ex) {
            System.out.println("RemoteTableServer err: " + ex.getMessage());
            ex.printStackTrace();
        }
    }
}
